/**
 * Created by Administrator on 2018/1/29.
 *
 *
 * 使用方法
 * YUE.__INIT__(回调函数，交易号)   //回调函数的参数有  交易号和用户输入的密码 【注：修改密码   可以不传交易号 即 回调获取的交易号为空】
 *
 *
 */
///////////////////////////////////////////////////////////////余额支付
var YUE = {};

YUE.code = 0;

YUE.action = function () {
};

YUE.value = [];

YUE.__INIT__ = function (action, code) {
    var source = $(".yue_pwd_input").html();
    if (!source) {
        $.get("src/tool/yue/yue.html", function (data) {
            $(".view").append(data);
            YUE.init_code(code);
            YUE.init_action(action);
        });
    } else {
        YUE.init_code(code);
        YUE.init_action(action);
    }
}

YUE.init_code = function (code) {
    myApp_.pickerModal('.yue_pwd_input');
    YUE.code = code;
    YUE.clear();
};

YUE.init_action = function (action) {
    YUE.action = action;// 回调方法
};


YUE.click = function (e) {
    if (e == 'cancel') {
        myApp_.closeModal('.yue_pwd_input');
        YUE.value = [];
    } else if (e == 'delete') {
        YUE.value = [];
    } else {
        YUE.value.push(e);
    }
    YUE.update();
};

YUE.update = function () {
    $(".YUE_input input").each(function (index, e) {
        var v = YUE.value[index] ? "*" : '';
        $(e).val(v);
    });
    if (YUE.value.length == 6) {
        YUE.action(YUE.code, YUE.value.join(""));
        myApp_.closeModal('.yue_pwd_input');
        YUE.clear();
    }
};


YUE.clear = function () {
    YUE.value = [];//初始化数据
    YUE.update();
};

YUE.is_set_pwd = function(action, code){
	var url = url_('index/User/is_set_pay_password');
	var data = {};
	var success = function(d){
		if (d.code == 0) {
			YUE.__INIT__(action, code)
		} else{
			my_tips_('请先设置支付密码',function(){
				go_href_('#/accent_setting');
			});
		}
	}
	request_(url,data,success)
}
